import { create_msg_commit_job } from "../chat/create_msg_commit_job";
import { create_contact_commit_job } from "../contact/create_contact_commit_job";
import { create_session_commit_job } from "../session/create_session_commit_job";
import { TasksKeeper } from "./TasksKeeper";
import { ITaskTypeCreatorMap, ITaskTypeDataMap, TaskType } from "./TaskType";

const creator_map: ITaskTypeCreatorMap = {
  [TaskType.Message]: create_msg_commit_job,
  [TaskType.Contact]: create_contact_commit_job,
  [TaskType.Session]: create_session_commit_job
}
let inst: TasksKeeper<TaskType, ITaskTypeDataMap> | null = null;
export const tasks_keeper = (): TasksKeeper<TaskType, ITaskTypeDataMap> => {
  if (!inst) inst = ((window as any).tasks) = TasksKeeper.create<TaskType, ITaskTypeDataMap>(creator_map);
  return inst;
}
